package com.ybzl.system.config;

import com.ybzl.system.mdc.MdcFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class DgtConfig implements WebMvcConfigurer {

    @Bean
    public FilterRegistrationBean<MdcFilter> mdcFilter() {
        FilterRegistrationBean<MdcFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new MdcFilter());//注册自定义过滤器
        bean.setName("mdcFilter");//过滤器名称
        bean.addUrlPatterns("/*");//过滤所有路径
        bean.setOrder(1);//优先级，越小越优先
        return bean;
    }
}
